<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../js/mui.js"></script>
		<script src="../js/config.js"></script>
		<link href="../css/mui.css" rel="stylesheet" />
		<style>
			html,
			body {
				height: 100%;
			}

			body {
				margin: 0;
			}

			.img_content {
				width: 100%;
				height: 100%;
				position: relative;
			}

			.into {
				width: 100%;
				bottom: 5%;
				position: absolute;
				z-index: 100;
				text-align: center;
			}

			.intoButton {
				width: 219px;
				display: inline-block;
				color: white;
				border: 1px solid #fff;
				border-radius: 20px;
				padding: 5px;
			}

			.ipconfig {
				height: 30px;
				width: 120px;
				top: 5%;
				right: 5%;
				position: absolute;
				z-index: 100;
				line-height: 30px;
				border-radius: 10px;
				text-align: center;
				background-color: #fff;
				color: #0B83FF;
			}
		</style>
	</head>

	<body style="overflow: hidden;">
		<div class="mui-content" style="height: 100%;">
			<div class="img_content">
				<img src="../image/guide3.png" style="width: 100%;height: 100%;">
				<div class="into">
					<div class="intoButton">
						立即体验
					</div>
				</div>

				<div class="ipconfig">
					<div>服务地址设置</div>
				</div>
			</div>


		</div>
	</body>
</html>
<script type="text/javascript">
	let backend = localStorage.getItem('backend');
	console.log('是否开启后端支持', backend)
	mui.init()
	mui.plusReady(function() {
		let first = localStorage.getItem('first');
		if (first == 'N') {
			let token = localStorage.getItem('token');
			if (!token) {
				console.log('手动登录')
				mui.openWindow({
					url: "login.html",
					id: "login.html",
					createNew: false,
					show: {
						autoShow: false,
					}
				})
			} else {
				console.log('自动登录');
				mui.openWindow({
					url: '../index.html',
					id: '../index.html',
					createNew: true,
					show: {
						autoShow: true,
					}
				});
			}
			// plus.webview.currentWebview().close();
		}

		if (backend == '0') {
			document.querySelector('.ipconfig').style.display = "none";
		}

		/**
		 * 获取本地存储中launchFlag的值intoButton
		 * http://www.html5plus.org/doc/zh_cn/storage.html#plus.storage.getItem
		 * 若存在，说明不是首次启动，直接进入首页；
		 * 若不存在，说明是首次启动，进入引导页；
		 */
		mui('body').on('tap', '.ipconfig', function() { //
			mui.openWindow({
				url: "ipconfig.html",
				id: "ipconfig.html",
				createNew: false,
				show: {
					autoShow: true,
				}
			})

		})

		mui('body').on('tap', '.intoButton', function() {
			localStorage.setItem('first', 'N');
			if (backend == '1') {
				if (localStorage.getItem("ip")) {
					mui.openWindow({
						url: "login.html",
						id: "login.html",
						createNew: false,
						show: {
							autoShow: true,
						}
					})
					plus.webview.currentWebview().hide()
				} else {
					mui.toast("请配置后台服务地址");
				}
			} else {
				mui.openWindow({
					url: "home.html",
					id: "home.html",
					createNew: false,
					show: {
						autoShow: true,
					}
				})
				plus.webview.currentWebview().hide()
			}
		})

	});
</script>